home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
74381
/
74381.xpi
/
content
/
multicolumnbookmarks.js
< prev
Wrap
Text File
|
2010-02-13
|
3KB
|
64 lines
if(!MaximKudimov) var MaximKudimov={};
if(!MaximKudimov.Multicolumnbookmarks) MaximKudimov.Multicolumnbookmarks={};
MaximKudimov.Multicolumnbookmarks = {
// nc - number of cols
// var popup = document.getElementById("bookmarksMenuPopup"); - object of bookmark menu
// document.defaultView.getComputedStyle(popup, null).getPropertyValue("line-height") - computed field - line height
// window.screenY - position of top left corner of all firefox. can be < 0, for example -4 if firefox is maximized
// window.screen.height - size of screen for example 1024x768
// popup.childNodes.length - count of bookmarks
// popup.popupBoxObject.screenX - absolute position of top corner of popup menu
onLoad: function() {
// initialization code
this.initialized = true;
var popup = document.getElementById("bookmarksMenuPopup");
popup.setAttribute('class', "popup-columns");
//popup.addEventListener('popupshowing', function() { MaximKudimov.Multicolumnbookmarks.setcolBefore(); }, false);
popup.addEventListener('popupshown', function() { MaximKudimov.Multicolumnbookmarks.setcolAfter(); }, false);
},
setcolAfter: function()
{
var popup = document.getElementById("bookmarksMenuPopup");
var cntr;
var AllHeight = 0;
var cldn=popup.childNodes;
for (cntr in cldn)
{
var obj = cldn[cntr].boxObject;
if (obj) AllHeight += obj.height;
}
var sizeBook;
if (popup.parentNode.boxObject.screenY > popup.popupBoxObject.screenY)
sizeBook = popup.parentNode.boxObject.screenY;
else
sizeBook = window.screen.height - popup.popupBoxObject.screenY;
var nc = Math.ceil(AllHeight / sizeBook);
nc = nc>4?4:nc;
var popup = document.getElementById("bookmarksMenuPopup");
var scrb = document.getAnonymousNodes(popup)[0].childNodes[1];
var boxcol = document.getAnonymousNodes(scrb );
scrb = document.getAnonymousNodes( boxcol[1] )[0];
scrb.setAttribute("style", "display: block; -moz-column-gap: 2em; -moz-column-count: "+nc+";");
},
setcolBefore: function()
{
var popup = document.getElementById("bookmarksMenuPopup");
var lineHeight = Number(document.defaultView.getComputedStyle(popup, null).getPropertyValue("line-height").replace("px", ""))*1.5;
var nc = Math.ceil(popup.childNodes.length * lineHeight /
(window.screen.height - popup.popupBoxObject.screenY));
nc = nc>4?4:nc;
var scrb = document.getAnonymousNodes(this )[0].childNodes[1];
var boxcol = document.getAnonymousNodes(scrb );
scrb = document.getAnonymousNodes( boxcol[1] )[0];
scrb.setAttribute("style", "display: block; -moz-column-gap: 2em; -moz-column-count: "+nc+";");
}
};
window.addEventListener("load", function() {MaximKudimov.Multicolumnbookmarks.onLoad();}, false);